home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 235 / Issue 235 - September 2007 - DPCS0907DVD.ISO / Microsoft / Expression Blend / Blend.en.msi / Sparkle.VShelf.Window1.xaml.cs.en < prev    next >
Encoding:
Text File  |  2007-03-19  |  4.7 KB  |  68 lines

  1.  ■using System;
  2. using System.IO;
  3. using System.Net;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using System.Windows.Data;
  7. using System.Windows.Media;
  8. using System.Windows.Media.Animation;
  9. using System.Windows.Navigation;
  10. using System.Diagnostics;
  11. namespace VideoShelf
  12. {
  13.     public partial class Window1
  14.     {
  15.         MediaElement player;
  16.         TextBlock timeElapsed;
  17.         FrameworkElement progress;
  18.         FrameworkElement track;
  19.         public Window1()
  20.         {
  21.             this.InitializeComponent();
  22.         }
  23.         /// <summary>
  24.         /// Updates the progress bar and clock of the player.
  25.         /// </summary>
  26.         void VisualTarget_Rendering(object sender, EventArgs e)
  27.         {
  28.             if (player.NaturalDuration.HasTimeSpan) progress.Width = (player.Position.TotalSeconds / player.NaturalDuration.TimeSpan.TotalSeconds) * track.ActualWidth;
  29.             TimeSpan tCode = TimeSpan.Parse(player.Position.ToString().Split('.')[0]);
  30.             timeElapsed.Text = tCode.ToString();
  31.         }
  32.         /// <summary>
  33.         /// Updates the current video information to be used by VisualTarget.Rendering.
  34.         /// </summary>
  35.         private void OnMediaOpened(object sender, RoutedEventArgs e)
  36.         {
  37.             VisualTarget.Rendering -= new EventHandler(VisualTarget_Rendering);
  38.             player = sender as MediaElement;
  39.             timeElapsed = (TextBlock)LayoutRoot.FindName("time" + player.Name.ToString());
  40.             progress = (FrameworkElement)LayoutRoot.FindName("progress" + player.Name.ToString());
  41.             track = (FrameworkElement)LayoutRoot.FindName("track" + player.Name.ToString());
  42.             VisualTarget.Rendering += new EventHandler(VisualTarget_Rendering);
  43.         }
  44.         private void OnMediaClosed(object sender, RoutedEventArgs e)
  45.         {
  46.             VisualTarget.Rendering -= new EventHandler(VisualTarget_Rendering);
  47.         }
  48.         private void OnExit(object sender, RoutedEventArgs e)
  49.         {
  50.             this.Close();
  51.         }
  52.         /// <summary>
  53.         /// Opens internet browser from the application.
  54.         /// </summary>
  55.         private void OnDownload(object sender, RoutedEventArgs e)
  56.         {
  57.             Process.Start("http://www.microsoft.com/windows/windowsmedia/musicandvideo/hdvideo/HDVideo.aspx");
  58.         }
  59.     }
  60. }